Skip to content

fix(cursor): mcp.json servers using ${workspaceFolder} now start - #24505

Merged
juliusmarminge merged 20 commits into
pingdotgg:mainfrom
only21mil:fix/i22199-cursor-provider-fails-to-start-project-m
Nov 12, 2026
Merged

juliusmarminge merged 20 commits into
pingdotgg:mainfrom
only21mil:fix/i22199-cursor-provider-fails-to-start-project-m

Conversation

@only21mil

@only21mil only21mil commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A .cursor/mcp.json server started as node ${workspaceFolder}/server.mjs works in the Cursor editor but crashes in Cursor threads in T3: the bundled Cursor SDK leaves Cursor's editor variables literal, so Node exits with MODULE_NOT_FOUND.

Change

When the Cursor adapter opens an agent, it reads the same two files, resolves the editor variables in each stdio server whose executable or leading script path uses one, and passes that copy as an agent-level MCP server.

  • ${workspaceFolder} is the project root: the output of git rev-parse --show-toplevel, matching the SDK, with the cwd as fallback.

  • The SDK loads agent-level servers first and keeps the first per name, so the resolved client wins after both sources have loaded. This is the agent-level path https://git.cafe/pingdotgg/t3code/pulls/15875 kept for the t3-code server; it merges with file servers instead of replacing them.

  • Servers without editor variables in their executable or leading non-flag argument are left alone. Env-only, cwd-only, and trailing argument placeholders remain with the SDK, avoiding extra healthy processes.

Scope

Bug fix: a server the user configured crashes at start in Cursor threads. Fixes https://git.cafe/pingdotgg/t3code/issues/22199.

Verification

Head 4ea0d8d161042c3c4e38b2590012e6d4e822152d merges current main without rebasing. The only merge conflict was imports; main's orchestration prompt and the workspace loader are both preserved.

  • Blacksmith vp run check:changed passed formatting, lint, both knip passes, unused-patch install validation, 39 affected package typechecks, and 23 tests.
  • All 22 Cursor adapter tests passed. The existing workspace case first failed with unwanted env-only and cwd-only injections, then passed after limiting qualification to startup paths. The same case failed with an unwanted trailing-argument server and a missing custom timeout before the second fix; both now pass. No new test file.
  • Full authenticated Cursor use through the T3 client remains unverified: this VM has no Cursor credentials. Windows, native desktop/mobile, remote/relay/tunnel paths remain unverified this pass.
  • SDK limitation: source clients start before deduplication. The issue's unresolved script path fails while the resolved client wins. Only executable or leading non-flag script paths qualify; trailing argument placeholders are left with the SDK. Preventing duplicate startup for every possible executable convention would need SDK support for suppressing selected file definitions.

No UI changes. Historical evidence from the original implementation follows; it does not establish authenticated client integration.

Current scope, head 1ebaebb3cf

The launch-path-only sentences in Change, Verification and Takeover verification describe an earlier scope, before e49122c6e1.

On this head, a stdio server with an editor variable anywhere in its definition, or an unset ${env:NAME}, gets a resolved copy. The agent starts with T3's MCP server only; each turn sends it plus the resolved servers, read again (e2910ec7a6), because Cursor SDK 1.2.0 replaces the agent's set with the turn's.

To see it on Linux web: sign in to Cursor in Settings > Providers, open a project whose .cursor/mcp.json starts node ${workspaceFolder}/server.mjs, and ask a Cursor thread to call its tool.

Signed-in run, main first, with sample-off disabled and sample-later disabled between turns. Main fails both turns and starts no server; on cf589210d1 each enabled server starts once per turn and sample-off never starts. The runs were on cf589210d1; 1ebaebb3cf then stops sending an empty server set with a turn and makes the server bundle use jsonc-parser's ESM entry, so the built server starts.

Main bfec275, turn 1: MCP server does not exist: sample-tools, no echo reply
Main bfec2754b8, turn 1: MCP server does not exist: sample-tools, no echo reply

cf58921, turn 1: sample-tools says: marker-one; tools sample_later_echo and sample_tools_echo
cf589210d1, turn 1: sample-tools says: marker-one; tools sample_later_echo and sample_tools_echo

cf58921, turn 2, sample-later switched off: marker-two; only sample_tools_echo
cf589210d1, turn 2, sample-later switched off: marker-two; only sample_tools_echo

Not checked here: Windows (run in the thread on 1b60d28), desktop and mobile (no client code changed), remote, relay and tunnel, and ${userHome} in a user-level server when the runtime cwd is null.

Send logs, checks, start logs and the longer description

Head 1ebaebb3cf: maria-rcks's 1b60d28cb6, one merge of main bfec2754b8, then e2910ec7a6 (fix), cf589210d1 (test only) and 1ebaebb3cf (no empty server set sent with a turn; the server bundle resolves jsonc-parser's ESM entry). The signed-in run below was on cf589210d1. I ran a signed-in Cursor thread on test servers named "Test machine": Cursor signed in through T3's browser sign-in, Composer 2.5, Cursor SDK 1.2.0, web client in T3's Browser panel, prompts typed in the Browser panel. Main ran first, then cf589210d1. The project's .cursor/mcp.json has three stdio servers started as node ${workspaceFolder}/server.mjs <name>. sample-off is listed in Cursor's mcp-disabled.json, and I added sample-later to that list between turn 1 and turn 2. Each server writes a line to a log when it starts.

The adapter's own send log, run.start options without the message text. Main bfec2754b8:

$ python3 -I /mnt/tools/trace.py provider/events.cdb0431e-13ff-4095-ba28-420faf35235d.log
2026-11-12T07:50:44.326Z {"options": {"hasMcpServers": true, "mcpServerNames": ["t3-code"], "mode": "agent", "model": {"id": "composer-2.5", "params": [{"id": "fast", "value": "false"}]}}, "type": "run.start"}
2026-11-12T07:51:53.995Z {"options": {"hasMcpServers": true, "mcpServerNames": ["t3-code"], "mode": "agent", "model": {"id": "composer-2.5", "params": [{"id": "fast", "value": "false"}]}}, "type": "run.start"}

cf589210d1:

$ python3 -I /mnt/tools/trace.py provider/events.fc8efc2b-509e-4353-8278-606204ac46c4.log
2026-11-12T09:48:52.580Z {"options": {"hasMcpServers": true, "mcpServerNames": ["sample-later", "sample-tools", "t3-code"], "mode": "agent", "model": {"id": "composer-2.5", "params": [{"id": "fast", "value": "false"}]}}, "type": "run.start"}
2026-11-12T09:49:19.082Z {"options": {"hasMcpServers": true, "mcpServerNames": ["sample-tools", "t3-code"], "mode": "agent", "model": {"id": "composer-2.5", "params": [{"id": "fast", "value": "false"}]}}, "type": "run.start"}

Main now sends T3's MCP server with every turn, and in Cursor SDK 1.2.0 a server set sent with a turn replaces the set the agent was created with. A plain merge would send only t3-code, so the resolved servers would drop out. The merge sends them with each turn. e2910ec7a6 resolves them again on each turn and creates the agent with T3's server only: with the merge alone, the same run started sample-later again on turn 2, and passing the resolved servers at creation as well started each server twice. cf589210d1 makes the workspace-variable test expect the root that git rev-parse --show-toplevel prints, which uses forward slashes on Windows.

On cf589210d1, vp run check:changed passes and all 131 provider-cursor tests pass on Node 26.12.1; the extended workspace-variable test fails with main's adapter.ts and with the merge's adapter.ts, and passes. On 1ebaebb3cf, the same 131 tests pass, four apps/server suites that replay Cursor pass (20 tests; the 12 replay-fixture and recovery tests among them fail on cf589210d1), vp run check:changed passes, and the built server starts.

Main bfec2754b8, after both turns:

$ cat /mnt/demo/sample/mcp-starts.log
cat: /mnt/demo/sample/mcp-starts.log: No such file or directory
$ cat /mnt/home/.cursor/projects/mnt-demo-sample/mcp-disabled.json
["sample-off","sample-later"]

cf589210d1, after both turns:

$ cat /mnt/demo/sample/mcp-starts.log
2026-11-12T09:48:53.238Z started sample-tools
2026-11-12T09:48:53.247Z started sample-later
2026-11-12T09:48:57.669Z called sample_tools_echo
2026-11-12T09:49:19.124Z started sample-tools
2026-11-12T09:49:23.007Z called sample_tools_echo
$ cat /mnt/home/.cursor/projects/mnt-demo-sample/mcp-disabled.json
["sample-off","sample-later"]

Main bfec275, turn 2: the same failure, MCP server does not exist: sample-tools
Main bfec2754b8, turn 2: the same failure, MCP server does not exist: sample-tools

Longer description, as written before this head:

Fixes https://git.cafe/pingdotgg/t3code/issues/22199. A .cursor/mcp.json server with "args": ["${workspaceFolder}/server.mjs"] works in the Cursor editor, but Cursor threads in T3 never get it.

The bundled Cursor SDK reads .cursor/mcp.json and ~/.cursor/mcp.json itself, and it expands only environment placeholders (${env:NAME}, ${NAME}, ${NAME:-default}). Cursor's editor variables (${workspaceFolder}, ${workspaceFolderBasename}, ${userHome}, ${pathSeparator}, ${/}) stay literal. Node then looks for a file named ${workspaceFolder}/server.mjs and exits with MODULE_NOT_FOUND. SDK 1.0.40 and 1.1.0-beta.0 do the same, so an SDK bump does not fix it.

Bug fix for https://git.cafe/pingdotgg/t3code/issues/22199. A maintainer reproduced the setup in this comment and could not go further without an authenticated Cursor account. The change stays inside the Cursor adapter.

The SDK still handles everything else: A project server shadows a user server with the same name, as in the SDK. A server listed in Cursor's mcp-disabled.json for the project stays off. A server named like a plugin server (plugin-<plugin>-<name>) is left to the SDK, which prefers enabled plugin servers over file servers. Environment placeholders resolve from the Cursor provider's environment before the file is validated, as in the SDK, so "type": "${env:MCP_TYPE}" is accepted. The SDK still loads its own unresolved copy. Only the resolved copy reaches the agent, because the first server per name wins. In the issue's setup the unresolved copy exits at once with a load warning, as it does today. jsonc-parser (the version apps/web uses) parses the files, since Cursor allows comments and trailing commas in mcp.json.

Prior PRs:

Takeover fixup and verification by gpt-6.1-sol through the Codex harness in T3 Code.

Takeover verification

The final scope remains five files, 323 additions and 2 deletions against current main. Custom startupTimeoutSec is preserved. Main was merged, never rebased. The old filesystem-probe bot finding was replied to and resolved because that code no longer exists.

The actual loader and SDK 1.0.38 workspace initialization were exercised together using isolated state and real stdio MCP handshakes:

env-only candidate:          1 spawned, 1 initialized
trailing-argument candidate: 1 spawned, 1 initialized
old env-only injection:      2 spawned, 2 initialized
resolved script candidate:  1 spawned, 1 initialized

All probe children exited and temporary state was removed. This verifies SDK startup, not an authenticated Cursor model turn through the T3 client. That client verification remains blocked by missing Cursor credentials. One independent reviewer cleared the final script-path scope; the second hit a provider rate limit and returned no verdict. Macroscope requires human approval. Final CI status is tracked in the takeover comment.

Fixes #22199

Generated with Claude Opus 5.5 and GPT-6.1 Sol in T3 Code Nightly

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Cursor provider fails to start project MCP servers using ${workspaceFolder} and unresolved environment variables

5 participants